import type {
  CalculationStatusMonitoringSelectCalculationStatusPageParams as A,
  AjaxPagingResult,
  CalculationStatusMonitoringSelectCalculationStatusPageResult1 as B,
  CalculationStatusMonitoringSelectCalculationStatusPageResult2 as C,
  CalculationStatusMonitoringPublicParams,
  CalculationStatusMonitoringPublicResult,
  CalculationStatusMonitoringUpdateDataByOneselfParams,
} from '@/types'

const controller = getAjaxBaseUrl(
  '/calculationStatusMonitoring',
  '/compute',
)

/** 重新计算结果 */
export function reCalculation(params: CalculationStatusMonitoringPublicParams) {
  return get(`${controller}/reCalculation`, params)
}

/** 查询指标计算关系图 */
export function selectCalculateRelationships(params: Omit<
    CalculationStatusMonitoringPublicParams,
    'indicatorName'
  >) {
  return get<CalculationStatusMonitoringPublicResult | null>(
    `${controller}/selectCalculateRelationships`,
    params,
  )
}

/** 查看执行流程 */
export function selectExecutionProcess(params: Omit<
    CalculationStatusMonitoringPublicParams,
    'indicatorName'
  >) {
  return get<string | null>(
    `${controller}/selectExecutionProcess`,
    params,
  )
}

/** 分页查询计算状态 */
export function selectCalculationStatusPage(params: Partial<A>) {
  return post<AjaxPagingResult<B[] | C[]>>(
    `${controller}/selectCalculationStatusPage`,
    params,
  )
}

/** 使用自定义数据更新数据 */
export function updateDataByOneself(params: CalculationStatusMonitoringUpdateDataByOneselfParams) {
  return post(`${controller}/updateDataByOneself`, params)
}
